package cn.itcast.bos.web.filter;

import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @author: SOS
 * @create: 2018-03-01 19:59
 */
public class BosFilter extends StrutsPrepareAndExecuteFilter {

    //过滤器
    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException,
            ServletException {
        //0.获取请求路径
        HttpServletRequest request = (HttpServletRequest) req;
        String requestURI = request.getRequestURI(); //bos_management/service/customerService/

        if (requestURI.contains("/service/")) {
            //说明是webservice服务,直接放行

            chain.doFilter(request,res);
        }else {
            //说明是struts请求则增强方法
            super.doFilter(request,res,chain);
        }
    }
}
